<?php
define('FROM_INDEX', true);
define('ROOT_PATH', dirname(__FILE__).'/');

require ROOT_PATH.'include/lib/load_setting.php';
load_setting('config_global');
load_setting('site_setting');
@header('Content-Type: text/html; charset='.CHARSET);

require ROOT_PATH.'include/function/global.func.php';
require_once ROOT_PATH.'include/lib/image.func.php';
require_once ROOT_PATH.'include/logic/image.logic.php';

function make_thumb_image($image_id, $image_file)
{
	require_once ROOT_PATH.'lib/io.han.php';
	$IoHandler = new IoHandler();
		
	$image_path = ROOT_PATH.'data/images/face/default/';
	
	if(!is_dir($image_path))
	{
		$IoHandler->MakeDir($image_path);
	}

	$thumbwidth = $thumbheight = 0;
	$image_file_1 = $image_path.$image_id . "_1.jpg";
	$image_file_2 = $image_path.$image_id . "_2.jpg";

	list($thumbwidth, $thumbheight) = explode('*', SIZE_FACE_1);
	$result = image_resize($image_file, $image_file_1, $thumbwidth, $thumbheight, true);
	if(!$result && !is_file($image_file_1)) @copy($image_file, $image_file_1);
		
	list($thumbwidth, $thumbheight) = explode('*', SIZE_FACE_2);
	$result = image_resize($image_file, $image_file_2, $thumbwidth, $thumbheight);
	if(!$result && !is_file($image_file_2)) @copy($image_file, $image_file_2);
	
	return true;
}

/*
$face_image_path = ROOT_PATH.'data/face_images/';
			
require_once ROOT_PATH.'lib/io.han.php';
$IoHandler = new IoHandler();
$files = $IoHandler->ReadDir($face_image_path);

if(check_array($files))
{
	$image_id = 1;
	foreach($files as $img)
	{
		if(is_image($img))
		{
			make_thumb_image($image_id, $img);
			$image_id ++;
		}
	}
}
*/
	
$images = get_face_random('', 1);
var_dump($images);